<template>
	<view class="box">
			
		<input class="uni-input" focus placeholder="请输入搜索关键词" />
		<!-- 轮播图组件 -->
	   	<view class="uni-margin-wrap">
	   			<swiper class="swiper" circular  :autoplay="autoplay" :interval="interval"
	   				>
	   				<swiper-item v-for="item in swiperList">
						<image :src="item.src" mode=""></image>
	   				</swiper-item>
	   			</swiper>
	   		</view>
			<!-- 分类区域 -->
		   <view class="fl">
			   <view class="fll" v-for="item in cartList" :key="item.name">
			   	 <image :src="item.src" mode="" @click="item_name(item.name)"></image>
				 <span>{{item.name}}</span>
			   </view>
		   </view>
	      <!-- 领劵区域 -->
		  <view class="juan">
			  <view class="j"  v-for="item in couponList">
			  	  <view class="left">
		  	  	 <span>{{item.price}}</span>
				 <span>{{item.value.title}}</span>
		  	  </view>
			  <view class="right">
			  	 领取
			  </view>
			  </view>
		  	
		  </view>
		  <!-- 拼团 -->
		  <view class="p">
		  	 拼团
		  </view>
		  <view class="tuan">
		  	  <view class="group" v-for="item in grouplist">
		  	  	  <view class="tu">
		  	  	  	 <image :src="item.cover" mode=""></image>
		  	  	  </view>
				<view class="">
					{{item.title}}
				</view>
				<span></span>
				<view class="">
					<span class="s1"> ￥{{item.t_price}}</span>
					<span class="s2">￥{{item.price}}</span>
				</view>
		  	  </view>
		  </view>
	   <!-- 最新列表 -->
		  <view class="l">
		  	 <span class="s1">最新列表</span>
			 <span class="s2" @click="tz">查看更多</span>
		  </view>
		  <view class="list" v-for="item in mslist">
		  	   <view class="p">
		  	   	  <image :src="item.cover" mode=""></image>
		  	   </view>
			   <view class="lr">
			   	   <view class="lr1">
			   	     {{item.title}}
			   	   </view>
				   <view class="lr2">
				   	  <span class="r2-1">￥{{item.price}}</span>
					  <span class="r2-2">￥{{item.t_price}}</span>
				   </view>
			   </view>
		  </view>
		  <view class="foot">
		  	  <image src="https://tangzhe123-com.oss-cn-shenzhen.aliyuncs.com/dishaweb/08C9150BC2B163AEC012D6E544C75DD2.png" mode=""></image>
		  </view> 
   </view>
</template>

<script>
	import api from'../../api/api.js'
	export default {
		data() {
			return {
				swiperList: [],
				cartList:[],
				couponList:[],//优惠券
				show: false,
				mode: 'date',
				autoplay:true,
				interval:2000,
				page:1,
				grouplist:[],//拼团
				mslist:[]
			}
		},
		 onLoad() {
			 //调用轮播
             this.swiperlist()
			 //分类
			 this.getcart()
			 //优惠券
			 this.gcoupon()
			 //拼团
			 this.ggroup()
			 //秒杀列表
			 this.getmslist()
		},
		methods: {
			tz(){
				console.log(11)
				uni.switchTab({
					url:"/pages/list/index"
				})
			},
			item_name(name){//分类区跳转页面
				if(name=="考试"){
					this.$router.push('pages/list/ks')
				}
			},
			//秒杀列表
			async getmslist(){
				let res=await api.getlist({data:this.page})
				console.log(res,"list")
				this.mslist=res.data.rows
			},
			//拼团
			async ggroup(){
				let res=await api.getgroup()
				console.log(res,'gg')
				this.grouplist=res.data.rows
			},
			//优惠券
			async gcoupon(){
				let res=await api.getcoupon()
				console.log(res,"you")
				this.couponList=res.data
			},
			//分类
			async getcart(){
				let res=await api.getswiper()
				this.cartList=res.data[2].data
			},
           // 查询轮播图数据
           async swiperlist() {
           			let res=await api.getswiper()
					  console.log(res)
					  this.swiperList=res.data[1].data
           },
		}
	}
</script>

<style lang="scss">
	.box{
		width: 100%;
		height: 100%;
	}
	.foot{
		width: 100%;
		height: 300rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.list{
		width: 100%;
		height: 200rpx;
		// background-color: plum;
		display: flex;
		justify-content: space-around;
		align-items: center;
		.p{
			width: 300rpx;
			height: 170rpx;
			// background-color: #d39e00;
			margin-left: 20rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.lr{
			flex: 1;
			height:170rpx;
			display: flex;
			margin-left: 10rpx;
			flex-direction: column;
			justify-content: space-between;
			.lr2{
				.r2-1{
					color: red;
				}
				.r2-2{
					color: darkgray;
					font-size: 15rpx;
				}
			}
		}
	}
	.l{
		width: 100%;
		height: 95rpx;
		// background-color: pink;
		display: flex;
		justify-content: space-between;
		align-items: center;
	   .s1{
		   font-weight: 800;
		   font-size: 30rpx;
	   }
	   .s2{
	   		 color: darkgray;
	   }
	}
	.tuan{
		width: 100%;
		height: 300rpx;
		// background-color: aqua;
		display: flex;
        justify-content: space-between;
		overflow: auto;
		.group{
			width: 340rpx;
			height: 300rpx;
			// background-color: #ffc107;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			.tu{
				height: 190rpx;
				width: 337rpx;
				background-color: pink;
				margin-left: 10rpx;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.s1{
				color: red;
			}
			.s2{
				color: gainsboro;
				font-size: 20rpx;
			}
		}
	}
	.p{
		width: 100%;
		height: 115rpx;
		// background-color: plum;
		font-size: 40rpx;
		font-weight: 700;
		line-height: 115rpx;
		padding: 10rpx;
	}
	.juan{
		width: 100%;
		height: 170rpx;
		// background-color: aquamarine;
		margin-top: 10rpx;
         display: flex;
		 align-items: center;
		 // padding: 10rpx;
        // overflow: scroll;
	   overflow: auto;
	  justify-content: space-between;
	  .j{
		  width: 515rpx;
		  height: 128rpx;
		  display: flex;
		  justify-content: space-around;
		  margin-left: 40rpx;
		  	.left{
			width: 400rpx;
			height: 128rpx;
			background-color: #d39e00;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			color: white;
			// font-size: 30rpx;
			border-right: 4rpx dashed;
		
		}
		.right{
		    width: 115rpx;
			height: 128rpx;
			background-color: #ffc107;
			color: white;
			line-height: 130rpx;
			text-align: center;
			font-size: 40rpx;
		}
	  }
	
	}
	.fl{
		width: 100%;
		height: 320rpx;
		// background-color: aqua;
		display: flex;
       justify-content: space-around;
	 flex-wrap: wrap;
	align-items: center;
	margin-top: 10rpx;
		.fll{
			width: 25%;
			height: 142rpx;
			display: flex;
        flex-direction: column;
		justify-content: space-around;
		align-items: center;
			image{
			width: 70rpx;
			height: 70rpx;
		}
		}
	
	}
	.uni-margin-wrap{
		width: 730rpx;
		height: 300rpx;
		margin: auto;
		margin-top: 10rpx;
		.swiper{
			width: 100%;
			height: 100%;
	 swiper-item{
			width: 100%;
			height: 100%;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
	}
	
	.uni-input{
		width: 730rpx;
		height: 78rpx;
		background-color:rgb(245, 245, 241) ;
		text-align: center;
		margin: auto;
		margin-top: 10rpx;
		border-radius: 5rpx;
		font-size: 20rpx;
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
